﻿using System.Collections.Generic;
using System.IO;
using ExcelAutomator.Configuration;
using NUnit.Framework;

namespace ExcelAutomator.Tests.IntegrationTests.RangeExecutors
{
	[TestFixture]
	public class AssertEqualsTestFixture : ExcelServiceTestFixture
	{

		#region DoNotExecuteAnyFollowingExecutorIfAssertFails
		[Test]
		public void DoNotExecuteAnyFollowingExecutorIfAssertFails()
		{
			var assertCfg = new AssertConfiguration()
			                	{
			                		ActionId = "equals",
													Address = "Sheet1!A1",
													Value = "FooBar"
			                	};
			var rangeCfg = new RangeConfiguration()
			               	{
			               		ActionId = "clear",
			               		TargetAddress = "Sheet1!A1"
			               	};

			var cfg = new ExcelAutomatorConfiguration()
			          	{
			          		Settings = new SettingsConfiguration()
			          		           	{
			          		           		Input = @"Input\" + SourceWbName
			          		           	},
			          		ExecutionSets =
			          			new List<ExecutionSetConfiguration>()
			          				{
			          					new ExecutionSetConfiguration()
			          						{
			          							Id = "My Execution Set",
			          							Executors =
			          								new List<ExecutorConfigurationWrapper>()
			          									{
																		new ExecutorConfigurationWrapper("assert", Constants.ExecutorExtensionsNamespace, assertCfg),
																		new ExecutorConfigurationWrapper("range", Constants.ExecutorExtensionsNamespace, rangeCfg)
																	}
			          						}
			          				}
			          	};

			var sut = new ExcelAutomationService(cfg);

			sut.ExecuteAutomation();

			
			base.StartExcel();
			ResolveRangeValues(Path.Combine(InputFolderPath, SourceWbName), "Sheet1", "A1", a1 => Assert.That(a1, Is.EqualTo("TestData1")));
			base.QuitExcel();

		}
		#endregion


		
	}
}
